<template>
    <div id="app">
            <van-field v-model="username" label="文本" placeholder="请输入用户名" />
            <van-field v-model="password" type="password" label="密码" />
            <div></div>
            <button @click="login">登录</button>
        <van-button type="default">默认按钮</van-button>
        <van-button type="primary">主要按钮</van-button>
        <van-button type="info">信息按钮</van-button>
        <van-button type="warning">警告按钮</van-button>
        <van-button type="danger">危险按钮</van-button>
    </div>
</template>

<script>
import axios from "axios"
import Vue from 'vue';
import { Button,Field  } from 'vant';

Vue.use(Button).use(Field);
export default {
    data(){
        return{
            username:'',
            password:'',
            datalist:[]
        }
    },
    methods:{
        login(){
            if(!this.username.trim()||!this.password.trim()){
                alert("用户名或密码不能为空")
            }else if(this.username == this.password){
                alert("用户名密码不能相同")
            }else{
                setTimeout(()=>{
                //前端登录成功后会获取后端传递来的token令牌
                localStorage.setItem("token","sadasdasdasdas")
                //跳转到个人中心
                this.$router.push("/center")
            },1000)
            }
            

        }
    }
}
</script>